home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Miscellaneous / CopyPaste 3.3.4 / CopyPaste Tools Sourcecode / Selection Sort.c / UpdateSel.c < prev   
Encoding:
C/C++ Source or Header  |  1997-05-12  |  904 b   |  58 lines  |  [TEXT/KAHL]

  1. #include "ToolSort.h"
  2.  
  3. /*=========================================================================
  4. Module:        UpdateSel
  5.  
  6. Purpose:    Put seltxt into scrap.
  7.  
  8. Returns:    err
  9.  
  10. =========================================================================*/
  11.  
  12. UpdateSel( txt )
  13.     Handle    txt;        /* text to be placed into scrap */
  14.     {
  15.     
  16.     long    len;        /* length of txt */
  17.     long     err = 0;    
  18.     
  19.  
  20.  
  21.     if ( txt != NIL )
  22.         {
  23.         len = GetHandleSize( txt );
  24.         err = ZeroScrap();
  25.         if (err == noErr && len > 0)
  26.             {
  27.             HLock( txt );
  28.             err = PutScrap( len, 'TEXT', *txt );
  29.             HUnlock( txt );
  30.             }
  31.         }
  32.     else
  33.         err = Nil_Hand_Error;
  34.         
  35.     switch( err )
  36.         {
  37.         case noErr:
  38.             if ( len == 0 )
  39.                 err = Empty_Error;
  40.             else if ( len < 0 )
  41.                 err = Sys_Error;
  42.             break;
  43.         case noScrapErr:
  44.             err = Scrap_Error;
  45.             break;
  46.         case memFullErr:
  47.             err = Memory_Error;
  48.             break;
  49.         default:
  50.             if (err < 0)
  51.                 err = Sys_Error;
  52.         }
  53.             
  54.  
  55.  
  56.     return( err );
  57.     }
  58.